package com.hqyj.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hqyj.system.pojo.SysPermission;
import com.hqyj.system.dao.SysPermissionMapper;
import com.hqyj.system.service.ISysPermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 权限表 服务实现类
 * </p>
 *
 * @author rock
 * @since 2021-11-30
 */
@Service
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermission> implements ISysPermissionService {
    @Autowired
    SysPermissionMapper sysPermissionMapper;


    @Override
    public HashMap<String, Object> select(SysPermission a) {
        HashMap<String, Object> map = new HashMap<String, Object>();
        List<SysPermission> abc = sysPermissionMapper.selectByMap(map);
        return map;
    }

    @Override
    public HashMap<String, Object> update(SysPermission a) {
        HashMap<String, Object> map = new HashMap<String, Object>();

        //修改
        int num = sysPermissionMapper.updateById(a);
        if(num>0){
            map.put("info","保存成功");
        }else{
            map.put("info","保存错误");
        }
        return map;
    }

    @Override
    public HashMap<String, Object> add(SysPermission a) {
        HashMap<String, Object> map = new HashMap<String, Object>();
        //新增
        int num = sysPermissionMapper.insert(a);
        if(num>0){
            map.put("info","保存成功");
        }else{
            map.put("info","保存错误");
        }
        return map;
    }

    @Override
    public HashMap<String, Object> del(Integer id) {
        HashMap<String, Object> map = new HashMap<String, Object>();
        //删除
        int num = sysPermissionMapper.deleteById(id);
        if(num>0){
            map.put("info","保存成功");
        }else{
            map.put("info","保存错误");
        }
        return map;
    }
}
